<template>
  <div class="im-iq-topInput" style="margin-top:5px">
    <div>
      <el-button size="mini" type="primary" @click="handleQuery">查询</el-button>
      <el-button @click="taskOutQuery" type="primary" size="mini">
              查询当前位置出库任务
            </el-button>
            <el-drawer
              title="容器任务列表"
              :visible.sync="drawer.drawer"
              :with-header="false">
              <el-table :data="drawer.gridData">
              <el-table-column property="workbinStatus" label="缓存箱状态" width="150"></el-table-column>
              <el-table-column property="palletCode" label="容器编号" width="200"></el-table-column>
              <el-table-column property="roadway" label="巷道"></el-table-column>
              </el-table>
            </el-drawer>
    </div>
    <div class="im-iq-topInputList">
      <ul>
        <li>
          <el-input
            size="mini"
            v-model="workbinCode"
            placeholder="请输入内容"
          ></el-input>
          <span>缓存箱编号：</span>
        </li>
        <li>
          <el-input
            size="mini"
            v-model="mProductNumber"
            placeholder="请输入内容"
          ></el-input>
          <span>成品型号：</span>
        </li>
        <li>
          <el-input
            size="mini"
            v-model="barcode"
            placeholder="请输入内容"
          ></el-input>
          <span>条码：</span>
        </li>
        <li>
          <el-input
            size="mini"
            v-model="itemCode"
            placeholder="请输入内容"
          ></el-input>
          <span>图号：</span>
        </li>
        <li>
          <el-input
            size="mini"
            v-model="qualityCode"
            placeholder="请输入内容"
          ></el-input>
          <span>质量编号：</span>
        </li>
    </ul>
    </div>

  </div>
</template>
<script>
import request from "@/utils/request.js";
export default {
  name: "ImIqTopInput",
  data() {
    return {
      workbinCode: "",
      mProductNumber: "",
      itemCode: "",
      qualityCode: "",
      barcode: "",
      drawer:{
        gridData:[],
        drawer: false,
      },
      pageSize:20,
      pageNumber:1
    };
  },
  methods:{
    handleQuery(){
      request.post("/erpOutBill/erpOutWorkbinQuery",{
        searchParams: {
          workbinCode: this.workbinCode,
          itemCode: this.itemCode,
          qualityCode: this.qualityCode,
          barcode:this.barcode,
          mProductNumber: this.mProductNumber
        },
        pageParameter: {
          rows: this.pageSize,
          page: this.pageNumber,
        },
      }).then((res) => {
        // 将条件查找的数据传给Table
        this.$bus.$emit("ImFqSearchData", res.data);
        console.log("erp出库查询", res);
        if(res.data.retCode == 201) {
          this.$Alert({
            title: "失败",
            message: "查询失败",
            type: "error",
          });
        }
      })
    },
    taskOutQuery(){
      this.drawer.drawer = true;
      this.drawer.gridData = [];
      request.post("/MsSslShelvesRest/taskOutQuery",{}).then((res)=>{
        console.log("查询结果",res);
        this.drawer.gridData=res.data.result;
      })
    }
  },
  mounted(){
    this.$bus.$on('imIqPageSize',(e)=>{
      this.pageSize = e
      request.post("/erpOutBill/erpOutWorkbinQuery",{
        searchParams: {
          workbinCode: this.workbinCode,
          itemCode: this.itemCode,
          qualityCode: this.qualityCode,
          barcode:this.barcode,
          mProductNumber: this.mProductNumber
        },
        pageParameter: {
          rows: this.pageSize,
          page: this.pageNumber,
        },
      }).then((res) => {
        // 将条件查找的数据传给Table
        this.$bus.$emit("ImFqSearchData", res.data);
        console.log("erp出库查询", res);
      });
    })
    this.$bus.$on('imIqPageNumber',(e)=>{
      this.pageNumber = e
      request.post("/erpOutBill/erpOutWorkbinQuery",{
        searchParams: {
          workbinCode: this.workbinCode,
          itemCode: this.itemCode,
          qualityCode: this.qualityCode,
          barcode:this.barcode,
          mProductNumber: this.mProductNumber
        },
        pageParameter: {
          rows: this.pageSize,
          page: this.pageNumber,
        },
      }).then((res) => {
        // 将条件查找的数据传给Table
        this.$bus.$emit("ImFqSearchData", res.data);
        console.log("erp出库查询", res);
      });
    })
    this.$bus.$on('newSearch',()=>{
      request.post("/erpOutBill/erpOutWorkbinQuery",{
        searchParams: {
          workbinCode: this.workbinCode,
          itemCode: this.itemCode,
          qualityCode: this.qualityCode,
          barcode:this.barcode,
          mProductNumber: this.mProductNumber
        },
        pageParameter: {
          rows: this.pageSize,
          page: this.pageNumber,
        },
      }).then((res) => {
        // 将条件查找的数据传给Table
        this.$bus.$emit("ImFqSearchData", res.data);
        console.log("erp出库查询", res);
      });
    })
  }
};
</script>
<style scoped>
.el-select {
  width: 140px;
}
.el-input {
  width: 140px;
}
.im-iq-topInput {
  overflow: hidden;
}
.im-iq-topInputList {
  text-align: center;
}
.im-iq-topInput ul li {
  float: left;
  width: 23%;
  height: 30px;
  line-height: 30px;
  margin-right: 1%;
  margin-bottom: 5px;
}
.im-iq-topInput ul li span {
  float: right;
}
.im-iq-topInput ul li div {
  float: right;
}
</style>